/**
 * 
 */
package org.mspring.platform.task;

import java.util.Map;

import org.springframework.scheduling.annotation.Async;

/**
 * @author Gao Youbo
 * @since Feb 20, 2012
 */
public abstract class AbstractTask implements Task {

    @Async
    public void doAsyncTask(final Map<Object, Object> context) {
        // BlockingQueue queue = new LinkedBlockingQueue();
        // ThreadPoolExecutor executor = new ThreadPoolExecutor(3, 6, 1,
        // TimeUnit.DAYS, queue);
        // executor.execute(new Runnable() {
        // public void run() {
        // try {
        // AbstractTask.this.doTask(context);
        // } catch (Exception e) {
        // // TODO Auto-generated catch block
        // e.printStackTrace();
        // }
        // }
        // });
        // executor.shutdown();
        try {
            AbstractTask.this.doTask(context);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void doSyncTask(Map<Object, Object> context) {
        try {
            doTask(context);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    protected abstract void doTask(Map<Object, Object> paramMap) throws Exception;
}
